package com.eastfair.home.controller;

import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.home.dto.*;
import com.eastfair.home.entity.SupervisionItemManagement;
import com.eastfair.home.enumeration.BoothAcceptanceRecordAcceptanceTypeEnum;
import com.eastfair.home.service.SupervisionItemManagementService;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.eastfair.boot.controller.SuperController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.echo.core.EchoService;
import com.eastfair.core.base.R;
import com.eastfair.home.vo.SupervisionItemManagementVO;
import com.eastfair.home.vo.SupervisionItemQuestionVO;
import com.eastfair.venueservice.vo.ServiceSpecsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.eastfair.annotation.annotation.security.PreAuth;

import com.eastfair.boot.request.PageParams;
import com.eastfair.core.context.ContextUtil;


/**
 * <p>
 * 前端控制器
 * 监督项管理
 * </p>
 *
 * @author linan
 * @date 2022-11-29
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/supervisionItemManagement")
@Api(value = "SupervisionItemManagement", tags = "监督项管理")
@PreAuth(replace = "home:supervisionItemManagement:")
public class SupervisionItemManagementController extends SuperController<SupervisionItemManagementService, Long, SupervisionItemManagement, SupervisionItemManagementPageQuery, SupervisionItemManagementSaveDTO, SupervisionItemManagementUpdateDTO> {

    @Autowired
    private EchoService echoService;

    @Override
    public void handlerResult(IPage<SupervisionItemManagement> page) {
        // 想让返回值实现自动回显，请将此行代码打开
        // echoService.action(page);
    }
    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<SupervisionItemManagement> supervisionItemManagementList = list.stream().map((map) -> {
            SupervisionItemManagement supervisionItemManagement = SupervisionItemManagement.builder().build();
            //TODO 请在这里完成转换
            return supervisionItemManagement;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(supervisionItemManagementList));
    }



    /**
     * 处理参数
     *
     * @param params 分页参数
     */
    @Override
    public void handlerQueryParams(PageParams<SupervisionItemManagementPageQuery> params) {
        SupervisionItemManagementPageQuery pageQuery = params.getModel();

    }

    /**
     * 保存监督项管理
     * @param dto dto
     * @return R
     */
    @SysLog("添加监督项")
    @PostMapping(value = "/saveSupervisionItemManagement")
    public R<Boolean> saveSupervisionItemManagement(@RequestBody SupervisionItemManagementDTO dto){
        return R.success(baseService.saveSupervisionItemManagement(dto));
    }

    /**
     * 更新监督项管理启用状态
     * @param dto dto
     * @return R
     */
    @SysLog("修改监督项启用/禁用")
    @PostMapping(value = "/updateSupervisionItemManagement")
    public R<Boolean> updateSupervisionItemManagement(@RequestBody SupervisionItemManagementDTO dto){
        return R.success(baseService.updateSupervisionItemManagement(dto));
    }

    /**
     * 查询监督项管理
     * @param query query
     * @return R
     */
    @PostMapping(value = "/getSupervisionItemManagement")
    public R<List<SupervisionItemManagementVO>> getSupervisionItemManagement(@RequestBody SupervisionItemManagementQuery query){
        return R.success(baseService.getSupervisionItemManagement(query));
    }


    /**
     * 查询问卷.
     * @return the r
     */
    @ApiOperation("查询问卷")
    @PostMapping("/queryQuestion")
    public R<List<SupervisionItemQuestionVO>> queryQuestion(@RequestBody SupervisionItemManagementQuery query){
        return R.success(baseService.queryQuestion(query));
    }
}
